<!DOCTYPE html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        <button @click="inputVal='你好'">修改数据</button><br>
        用户名: <input type="text" v-model.trim="user.username"><br>
        密码: <input type="text" v-model.number="user.password"><br>
        性别：<input v-model="user.gender" name="gender" type="radio" value="male">男
        <input v-model="user.gender" name="gender" type="radio" value="female"> 女<br>
        爱好: <input v-model="user.hobby" type="checkbox" value="backetball"> 篮球
        <input v-model="user.hobby" type="checkbox" value="footboll"> 足球
        <input v-model="user.hobby" type="checkbox" value="pingpang"> 乒乓球<br>
        地址：<select v-model="user.address">
            <option value="beijing">北京</option>
            <option value="shanghai">上海</option>
            <option value="taiyuan">太原</option>
        </select><br>
        介绍：<textarea cols="30" rows="10" v-model="user.description"></textarea>
        <button @click="submitHandler">提交</button>
        <br>{{user}}
    </div>
    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                user: {
                    // 复选框有默认值，是个[]空数组
                    hobby: []
                },
            },
            methods: {
                submitHandler() {
                    // JSON.stringify 方法将某个对象转换成 JSON 字符串形式
                    let data = JSON.stringify(this.user)
                    console.log(data);
                }
            },
            created() {

            }
        })
    </script>

</body>

</html>